import { IDeptInfo, IDeptItem, IGetDeptListParams } from '@/types/dept'
import request from '@/utils/request'
import { AxiosPromise } from 'axios'
/**
 * 部门列表
 * @param params
 * @returns
 */
function getDeptList(params?: IGetDeptListParams): AxiosPromise {
  return request({
    url: '/dept/list',
    method: 'get',
    params
  })
}

/**
 * 创建部门
 * @param data
 * @returns
 */
function createDept(data: IDeptInfo): AxiosPromise {
  return request({
    url: '/dept/create',
    method: 'post',
    data
  })
}

/**
 * 编辑部门
 * @param data
 * @returns
 */
function editDept(data: IDeptItem): AxiosPromise {
  return request({
    url: '/dept/edit',
    method: 'post',
    data
  })
}

/**
 * 删除部门
 * @param id
 * @returns
 */
function deleteDept(id: string): AxiosPromise {
  return request({
    url: '/dept/delete',
    method: 'post',
    data: { _id: id }
  })
}

export { getDeptList, createDept, editDept, deleteDept }
